package com.sxyjhh.fg_data_push.po;

import com.sxyjhh.fg_data_push.utils.IdGenerator;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by Administrator on 2018/7/18.
 */

@Entity
@Table(name = "fg_data_push_recode")
public class FgDataPushRecode {
    @Id
    @Column(name = "ID")
    private String id;

    @Column(name = "TIME")
    private Date time;

    @Column(name = "NUM")
    private long num;

    @Column(name = "TOTAL_NUM")
    private long totalNum;

    @Column(name = "FINISHED_TIME")
    private long finishedTime;

    @Column(name = "DATA_TYPE")
    private String dataType;

    @Column(name = "INSERT_NUM")
    private long insertNum;

    @Column(name = "UPDATE_NUM")
    private long updateNum;

    @Column(name = "END_TIME")
    private Date endTime;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public long getNum() {
        return num;
    }

    public void setNum(long num) {
        this.num = num;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }


    public long getTotalNum() {
        return totalNum;
    }

    public void setTotalNum(long totalNum) {
        this.totalNum = totalNum;
    }

    public long getFinishedTime() {
        return finishedTime;
    }

    public void setFinishedTime(long finishedTime) {
        this.finishedTime = finishedTime;
    }

    public long getInsertNum() {
        return insertNum;
    }

    public void setInsertNum(long insertNum) {
        this.insertNum = insertNum;
    }

    public long getUpdateNum() {
        return updateNum;
    }

    public void setUpdateNum(long updateNum) {
        this.updateNum = updateNum;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    @PrePersist
    public void setInsertBefore() {

        // 插入数据前设置创建时间、修改时间和数据状态
        if (this.getId() == null || "".equals(this.getId())) {
            this.setId(IdGenerator.createNewId());
            Date dateTime = new Date();
            this.setTime(dateTime);
        }
    }
}
